<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@page import="iwpl.project.entities.Departments"%>
<%@page import="iwpl.project.entities.Areas"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@page import="iwpl.project.dao.*"  %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'ex1.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script language="javascript" src="js/prototype-1.6.0.2.js" type="text/javascript"></script>
	<script type="text/javascript">
		function chuyen()
		{
			var giatri=$('cbodep').value;
			var frm=$('frm');
			frm.action="/DepartmentManage/servlet/Control_Contract?action=ajax&&id="+giatri;
			frm.method="post";
			frm.submit();
		}
	</script>
	<script>
	function test1()
	{
		var d = $('myDiv');
		alert(d.innerHTML);
	}

	function test2()
	{
		var divs = $('myDiv','myOtherDiv');
		for(i=0; i<divs.length; i++)
		{
			alert(divs[i].innerHTML);
		}
	}
</script>
	
  </head>
  
  <body>
  <form method="post" id="frm">
    	<table>
    		<tr>
    			<td>
    				<%
    					DepartmentsDAO dao=new DepartmentsDAO();
    					Departments dep=new Departments();
    					List data=dao.findAll();
    					Iterator ir=data.iterator();
    					out.print("<select id=cbodep onchange=chuyen();>");
    					while(ir.hasNext())
    					{
    						dep=(Departments)ir.next();
    						int depid=dep.getId();
    						String depname=dep.getDepartmentName();
    						out.print("<option value="+depid+">"+depname+"</option>");
    					}
    					out.print("</select>");
    				 %>
    			</td>
    		</tr>
    	</table>
    	</form>
  </body>
</html>
